home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / findname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.2 KB  |  97 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: findname.c,v 1.6 1996/09/12 13:23:23 digulla Exp $
  4.     $Log: findname.c,v $
  5.     Revision 1.6  1996/09/12 13:23:23  digulla
  6.     Fixed a severe bug in the code. If nothing was found, the function returned
  7.         the list-header instead of NULL
  8.  
  9.     Revision 1.5  1996/08/13 13:56:01  digulla
  10.     Replaced __AROS_LA by __AROS_LHA
  11.     Replaced some __AROS_LH*I by __AROS_LH*
  12.     Sorted and added includes
  13.  
  14.     Revision 1.4  1996/08/01 17:41:10  digulla
  15.     Added standard header for all files
  16.  
  17.     Desc:
  18.     Lang: english
  19. */
  20. #define AROS_ALMOST_COMPATIBLE
  21. #include "exec_intern.h"
  22. #include <aros/libcall.h>
  23. #include <clib/aros_protos.h>
  24.  
  25. /*****************************************************************************
  26.  
  27.     NAME */
  28.     #include <exec/lists.h>
  29.     #include <clib/exec_protos.h>
  30.  
  31.     __AROS_LH2I(struct Node *, FindName,
  32.  
  33. /*  SYNOPSIS */
  34.     __AROS_LHA(struct List *, list, A0),
  35.     __AROS_LHA(UBYTE       *, name, A1),
  36.  
  37. /*  LOCATION */
  38.     struct SysBase *, SysBase, 46, Exec)
  39.  
  40. /*  FUNCTION
  41.     Look for a node with a certain name in a list.
  42.  
  43.     INPUTS
  44.     list - Search this list.
  45.     name - This is the name to look for.
  46.  
  47.     RESULT
  48.  
  49.     NOTES
  50.     The search is case-sensitive, so "Hello" will not find a node
  51.     named "hello".
  52.  
  53.     The list must contain complete Nodes and no MinNodes.
  54.  
  55.     EXAMPLE
  56.     struct List * list;
  57.     struct Node * node;
  58.  
  59.     // Look for a node with the name "Hello"
  60.     node = FindName (list, "Hello");
  61.  
  62.     BUGS
  63.  
  64.     SEE ALSO
  65.  
  66.     INTERNALS
  67.  
  68.     HISTORY
  69.     26-08-95    digulla created after EXEC-Routine
  70.     26-10-95    digulla adjusted to new calling scheme
  71.  
  72. ******************************************************************************/
  73. {
  74.     __AROS_FUNC_INIT
  75.     struct Node * node;
  76.  
  77.     assert (list);
  78.     assert (name);
  79.  
  80.     /* Look through the list */
  81.     for (node=GetHead(list); node; node=GetSucc(node))
  82.     {
  83.     /* check the node. If we found it, stop */
  84.     if (!STRCMP (node->ln_Name, name))
  85.         break;
  86.     }
  87.  
  88.     /*
  89.     If we found a node, this will contain the pointer to it. If we
  90.     didn't, this will be NULL (either because the list was
  91.     empty or because we tried all nodes in the list)
  92.     */
  93.     return node;
  94.     __AROS_FUNC_EXIT
  95. } /* FindName */
  96.  
  97.